import {
  customertallyslideorder,
  provideraccepttallyslideorder,
  providerrejecttallyslideorder,
  providertallyslideorder
} from "@/api/order/tally";

export const btnTally = [
  // 买家
  {
    name: "申请结单",
    clickEvent: "applyTallyOrder",
    flag: "applyTallyOrder"
  },
  //   卖家
  {
    name: "同意结单",
    clickEvent: "acceptTally",
    flag: "acceptTally"
  },
  {
    name: "拒绝结单",
    clickEvent: "rejectTally",
    flag: "rejectTally"
  },
  {
    name: "结单",
    clickEvent: "tallyOrder",
    flag: "tallyOrder"
  }
];

export const tally = {
  methods: {
    // 买家申请结单
    applyTallyOrder(row) {
      customertallyslideorder({
        orderId: row.id,
        version: row.version
      }).then(res => {
        this.$message.success("操作成功");
        this.$emit("handleSuccess", { data: res, type: "applyTallyOrder" });
      });
    },
    // 卖家同意结单
    acceptTally(row) {
      provideraccepttallyslideorder({
        orderId: row.id,
        version: row.version
      }).then(res => {
        this.$message.success("操作成功");
        this.$emit("handleSuccess", { data: res, type: "acceptTally" });
      });
    },
    // 卖家拒绝结单
    rejectTally(row) {
      providerrejecttallyslideorder({
        orderId: row.id,
        version: row.version
      }).then(res => {
        this.$message.success("操作成功");
        this.$emit("handleSuccess", { data: res, type: "rejectTally" });
      });
    },
    // 卖家结单
    tallyOrder(row) {
      providertallyslideorder({
        orderId: row.id,
        version: row.version
      }).then(res => {
        this.$message.success("操作成功");
        this.$emit("handleSuccess", { data: res, type: "tallyOrder" });
      });
    }
  }
};
